﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cosmetic.Logic;

namespace WebApp.Management
{
    public partial class AdminWelcome : PageBase2
    {
        private UserManager m_UserManager = new UserManager();
        private RoleManager m_RoleManager = new RoleManager();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.SignInUser1 == null)
            {
                Session.Remove("SignInUser1");
                this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, "alert('请先登录权限!');window.top.location.href='/Management/indexs.aspx';", true);
                return;
            }
            if (!IsPostBack)
            {
                Cosmetic.DataEntity.User theUser = this.SignInUser1;
                if (!this.m_RoleManager.CheckUserRole(theUser, RoleManager.ERole.Admin))
                {
                    Session.Remove("SignInUser1");
                    this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, "alert('你没有管理员权限!');window.top.location.href='/Management/indexs.aspx';", true);
                    return;
                }
            }
        }
    }
}